﻿using System;

using TRPOP.Common;
using TRPOP.CRM.Component.Business;
using TRPOP.CRM.Component.Common;
using TRPOP.CRM.Component.Model;

namespace TRPOP.CRM.Web
{
    public partial class Employee_photo : BaseAdmin
    {
        #region 页面变量
        public int m_intEmployeeID = 0;
        #endregion

        #region 页面事件
        protected void Page_Load(object sender, EventArgs e)
        {
            m_intEmployeeID = RequestHelper.RequestInt("employeeid");

            if (m_intEmployeeID <= 0)
            {
                Alert("参数传递错误！", "Employee_list.aspx");
                return;
            }

            if (!IsPostBack)
            {
                DownFile();
            }
        }
        #endregion

        #region 页面方法
        /// <summary>
        /// 下载照片
        /// </summary>
        private void DownFile()
        {
            EmployeeInfo oEmployeeInfo = null;

            try
            {
                oEmployeeInfo = EmployeeManage.GetEmployeeInfo(m_intEmployeeID);

                if (oEmployeeInfo != null)
                {
                    //员工头像信息展示
                    Response.Clear();

                    if (oEmployeeInfo.bnImageBinary != null)
                    {
                        byte[] bytEmployeeHead = (Byte[])oEmployeeInfo.bnImageBinary;
                        Response.ContentType = oEmployeeInfo.nvcImageBinaryExtension.Trim();
                        Response.BinaryWrite(bytEmployeeHead);
                    }

                    //Response.End();
                }
            }
            catch (Exception ex)
            {
                string strErrorMessage = "GetEmployeeHeadPhoto页面中的GetEmployee方法于" + DateTime.Now.ToString() + "发生错误，信息为( " + ex.Message.ToString() + " )";
            }
        }
        #endregion
    }
}